<template>
  <el-dialog v-if="popenevTVisible" title="请假详情" :visible.sync="popenevTVisible" :before-close="handleCancel" width="450px" :close-on-click-modal="false">
    <el-form ref="form" :model="form" label-width="120px">
      <el-row>
        <el-col :span="24">
          <el-form-item label="请假原因">
            <el-input v-model="form.qjyy" type="textarea" :rows="6" style="width:241px" placeholder="请输入请假原因"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="附件">
            <AttachmentView :showUpload="false" :hiddenDownload="true" :showDelete="false" :type="1" :relationUnid="unid" moduleName="xxfb"></AttachmentView>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </el-dialog>
</template>

<script>
import AttachmentView from "../AttachmentView"
import { getQjjl } from '../../api/commonApi'
import { mapGetters } from "vuex";
export default {
  components: {
    AttachmentView
  },
  data () {
    return {
      popenevTVisible: true,
      form: {},
      unid: '',
      hdid: ''
    }
  },
  computed: {
    ...mapGetters(["userInfo"]),
  },
  methods: {
    show(data, config)
    {
      console.log(data, 'data')
      console.log(config, 'config')
      this.unid = data.unid
      this.hdid = data.hdid
      this.getQjDetail()
      this.reset();
      // 创建promise
      return new Promise((resolve, reject) =>
      {
        this.promiseStatus = {
          resolve,
          reject,
        };
      });
    },
    // 获取请假详情
    getQjDetail()
    {
      var param = {
        personId: this.userInfo.unid,
        cmsArticleUnid: this.hdid
      }
      getQjjl(param).then(res => {
        console.log(res, '请假详情')
        if (res.code == 200)
        {
          if (res.result)
          {
            this.form.qjyy = res.result.qjyy
          }
        }
      })
    },
    // 表单重置
    reset()
    {
      this.form = {
        unid: this.unid,
        qjyy: ''
      };
      console.log(this.form);
      this.resetForm("form");
    },
    // 关闭弹框
    handleCancel()
    {
      //清空勾选项
      this.promiseStatus.reject({
        msg: "取消",
      });

      this.destroyElement();
    },
    // 销毁组件
    destroyElement()
    {
      this.popenevTVisible = false;
    }
  }
}
</script>

<style>

</style>